function newpassword(){
    if(document.getElementById('password1').value !== document.getElementById('password2').value){
        document.getElementById('passwordError').style.opacity = '1'
        document.getElementById('password2').value = ""
    }
}

function sendSms(){
    var tel = document.getElementById('telephone').value
    $.ajax({
        url:initObj.url + '/api/sms/sendSms/' + document.getElementById('country').value + tel + '/忘记密码',
        type:'get',
        datatype:'json',
        success:function(res){
            console.log(res)
        }
    })
    document.getElementById('sendSms').style.backgroundColor = "rgba(255, 255, 255, 0.5)"
    var timer2 = 60
    $("#sendSms").attr("disabled", "disabled");
    var timer1 = setInterval(() => {
        timer2--;
        document.getElementById('sendSms').innerHTML = timer2 + "秒后重新发送"
        if(timer2 == 0){
            $("#sendSms").removeAttr("disabled");
            document.getElementById('sendSms').style.backgroundColor = 'rgba(62, 65, 242, 0.7)'
            document.getElementById('sendSms').innerHTML = '发送验证码'
            clearInterval(timer1)
        }
    }, 1000);
}

function forget_OK(){
    var forget_form = {
        code:document.getElementById('forget_code').value,
        password:hex_md5(document.getElementById('password2').value),
        telephone:document.getElementById('telephone').value,
        country:document.getElementById('country').value
    }
    $.ajax({
        url:initObj.url + '/api/user/modifyPassword/' + forget_form.code + '/' + forget_form.password + '/' + forget_form.country + forget_form.telephone,
        type:'put',
        datatype:'json',
        success:function(res){
            console.log(res)
            if(res.status == 200){
                alert('密码修改成功')
                window.location.href = "../login.html"
            }
        }
    })
}